﻿using rmTest_6.Model;
using rmTest_6.ServiceInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rmTest_6.Access
{
    public class UserProcessorDecorator : IUserProcessor
    {
        private IUserProcessor _UserProcessor { get; set; }
        public UserProcessorDecorator(IUserProcessor userprocessor)
        {
            this._UserProcessor = userprocessor;
        }

        public void RegUser(User user)
        {
            BeforeProceed(user);

            this._UserProcessor.RegUser(user);

            AfterProceed(user);
        }

        public User GetUser(User user)
        {
            BeforeProceed(user);
            user = this._UserProcessor.GetUser(user);
            AfterProceed(user);
            return user;
        }
        /// <summary>
        /// 业务逻辑之前
        /// </summary>
        /// <param name="user"></param>
        private void BeforeProceed(User user)
        {
            Console.WriteLine("方法执行前");
        }
        /// <summary>
        /// 业务逻辑之后
        /// </summary>
        /// <param name="user"></param>
        private void AfterProceed(User user)
        {
            Console.WriteLine("方法执行后");
        }
    }

}
